﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ciripescu_WebRole.Properties;

namespace Ciripescu_WebRole
{
    public partial class widget_setup : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            btnGenereaza_Click(sender, e);
        }

        protected void btnGenereaza_Click(object sender, EventArgs e)
        {            
            string cod = Resources.WidgetCode;
            while (cod.IndexOf("$username") != -1)
                cod = cod.Replace("$username", (string)Session["UserName"]);
            while (cod.IndexOf("$titlu") != -1)
                cod = cod.Replace("$titlu", txtTitlu.Text);
            while (cod.IndexOf("$nr") != -1)
                cod = cod.Replace("$nr", ddlNrCiripuri.SelectedValue.ToString());
            if (chkTitlu.Checked)
                cod = cod.Replace("class=\"ciripescu-title\"", "style='display:none'");

            txtCopyPaste.Text = cod;
            Preview.InnerHtml = cod;
            nr.InnerHtml = ddlNrCiripuri.SelectedValue.ToString();
        }
    }
}
